package cn.itcast.hotel.config;

import cn.itcast.hotel.constant.EsConstant;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 初始化RestHighLevelClient
 *
 * @Author 15198
 * @Date 2022/8/5 16:20
 * @Description: 初始化RestHighLevelClient
 * @Created by
 */
@Configuration
public class RestClientConfig {


    @Bean
    public RestHighLevelClient client(){
        return new RestHighLevelClient(RestClient.builder(new HttpHost(EsConstant.ES_HOST,EsConstant.ES_POST)));
    }

    //消息转换器
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
}
